package org.endy.leisure.diaTracker.entity.announcement

import jakarta.persistence.Column
import jakarta.persistence.Entity
import jakarta.persistence.FetchType
import jakarta.persistence.GeneratedValue
import jakarta.persistence.GenerationType
import jakarta.persistence.Id
import jakarta.persistence.JoinColumn
import jakarta.persistence.ManyToOne
import jakarta.persistence.Table
import org.endy.leisure.diaTracker.entity.User
import java.util.Date

// 公告实体类
@Entity
@Table(name = "announcement")
data class Announcement(
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    var id: Long? = null,

    @Column(name = "title", nullable = false)
    var title: String,

    @Column(name = "content", nullable = false)
    var content: String,

    @Column(name = "type", nullable = false)
    var type:String,

    @Column(name = "publisher", nullable = false)
    var publisher: String, // 发布者：主任、护士长

    @Column(name = "image_url")
    var imagePath:String? = null,

    @Column(name = "create_time", nullable = false)
    var createTime: Date = Date(),

    @Column(name = "expire_time")
    var expireTime: Date? = null,

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id")
    val user: User,
)
